package com.jlpay.openapi.demo.cashier;

import com.jlpay.open.jlpay.sdk.java.model.cashier.request.TradeRefundRequest;
import com.jlpay.open.jlpay.sdk.java.model.cashier.response.TradeRefundResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/24
 **/
public class TradeRefundService {
    private static final Logger LOGGER = LoggerFactory.getLogger(TradeRefundService.class);

    public static void main(String[] args) {
        TradeRefundRequest tradeRefundRequest = buildTradeRefundRequest();
        TradeRefundResponse tradeRefundResponse = JlpayOpenApiService.openMerchService()
                .post(tradeRefundRequest, TradeRefundResponse.class);
        LOGGER.info("收银托管订单退款响应:{}", JsonUtils.toString(tradeRefundResponse));
    }

    private static TradeRefundRequest buildTradeRefundRequest() {
        TradeRefundRequest tradeRefundRequest = new TradeRefundRequest();

        tradeRefundRequest.setMerchNo("849584358120018");
        tradeRefundRequest.setOutTradeNo("ld201911023465530");
        tradeRefundRequest.setOriOutTradeNo("ld201911023465529");
        tradeRefundRequest.setTotalAmount("1");
        tradeRefundRequest.setRemark("备注信息");

        return tradeRefundRequest;
    }
}
